#include "s3c2440.h"
#include "led.h"

/*
*function name:led_init
*descrip:initial GPB[5:8] as output,these 4 ports connect to leds
*/
void led_init(void)
{
	unsigned int temp;
	temp = GPBCON;
	temp |= (01 << 10) | (01 << 12) |(01 << 14) | (01 << 16);
	temp &= ~((0x2 << 10) | (0x2 << 12) |(0x2 << 14) | (0x2 << 16));	
	GPBCON = temp;
}

/*
*function name:led_onoff
*descrip:on or off led
*/
void led_onoff(unsigned char lednum,unsigned char flag)
{
	unsigned int temp;
	
	if(flag == 0)
	{
		temp = GPBDAT;
		temp |= 1 << (lednum + 4);
	}
	else 
	{
		temp = GPBDAT;
		temp &= ~(1 << (lednum + 4));
	}
	
	GPBDAT = temp;
}
void led_loopdisp(void)
{
	
}

/*
*function name:led_debug
*descript:display the 4-bits data,'1':led off;'0':led on
*/
void led_debug(unsigned int worddata,unsigned int shifte)
{
	unsigned int temp;
	unsigned int temp1;
	temp = (worddata >> shifte) & 0xf;
	temp = temp << 5;
	temp1 = GPBDAT;
	temp1 &= ~(0x1e0);
	temp1 |= temp;
	GPBDAT = temp1;
}

